<template>
	<view class="container">
		<view v-for="(item,index) in items" :key="index">
			<view>
				<uni-card :title="item.title" :sub-title="item.time" :thumbnail="imgPath+img_status[item.status]"
					@click="cardClick(index)">
					<view> {{item.content}} </view>
					<view class="time-info">
						<view>
							<text>创建时间: {{ item.createTime }}</text>
						</view>
						<view>
							<text>修改时间: {{ item.updateTime }}</text>
						</view>
					</view>
				</uni-card>
			</view>
		</view>
		<uni-fab horizontal="left" vertical="bottom" @fabClick="onClick"> </uni-fab>
	</view>
</template>

<script>
	import {
		parseTime
	} from "@/utils/tool.js"
	//import { parseTime } from "@/utils/common.js";
	export default {
		data() {
			return {
				imgPath: "/static/image/",
				img_status: ["Not-started.png", "in-progress.png", "complete.png"],
				items: []
			};
		},
		onLoad() {
			this.getData()
		},
		methods: {
			cardClick(index) {
				uni.navigateTo({
					url: "/pages/detail/detail?funcode=1&&id=" + this.items[index]._id
				})
			},
			onClick() {
				uni.navigateTo({
					url: "/pages/detail/detail?funcode=0"
				})
			},
			getData() {
				uniCloud.callFunction({
					name: "CloudGetData",
					data: {
						type: 'all',
						id: "000"
					}
				}).then(res => {
					console.log(res)
					this.items = res.result.data
					for (let index in this.items) {
						if (!this.items[index].time) {
							this.items[index].time = Date.now()
						}
						this.items[index].time = parseTime(this.items[index].time);
						this.items[index].createTime = parseTime(this.items[index].createTime);
						this.items[index].updateTime = parseTime(this.items[index].updateTime);
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.uni-card .uni-card__header .uni-card__header-content .uni-card__header-content-title {
		font-size: 38rpx;
		font-weight: bold;
	}
	.time-info {
	    margin-top: 10rpx;
	    font-size: 26rpx;
	    color: #888;
	}
	.container {
		padding: 20rpx;
		font-size: 30rpx;
		line-height: 32rpx;
		background: #ffaa7f;
	}
</style>
